<?php


namespace app\api\service;


use app\common\cache\DiyCache;
use app\common\model\diy\Diy;
use tmcore\base\BaseService;

class DiyService extends BaseService
{
    /**
     * 查看diy数据
     * @param $params
     * @return array
     */
    public static function detail($params) : array
    {
        $Diy = (new Diy);

        $data = $Diy->getDiyCache($params['type'], $params['name']);
        $data = ($data && is_array($data))?$data:[];
        if(!empty($params['type']) && $params['type'] == 1 && ($params['name'] == 'home_page' || $params['name'] == 'person_center')) {
            $style_data = $Diy->getDiyCache(1, 'style');

            $data['info'] = [
                'style_identify' => !empty($style_data['identify'])?$style_data['identify']:'blue',
                'style_color' => !empty($style_data['color'])?$style_data['color']:'#2979ff'
            ];
        }

        return $data;
    }


}